package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Scanner;

public class JDBCDemo5 {
    public static void main(String[] args)  {
        try ( Connection connection = DBUtil.getConnection();){
            Statement statement = connection.createStatement();
            String str="select username,password,nickname,age from userinfo";
            ResultSet r = statement.executeQuery(str);
            while(r.next()){
                String username = r.getString("username");
                String password = r.getString("password");
                String nickname = r.getString("nickname");
                int age = r.getInt("age");
                System.out.println(username+"-"+password+"-"+nickname+"-"+age);
            }
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }
}
